package com.xym.jackson.test;

import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;
import org.junit.Test;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.xym.store.order.pojo.Order;

public class Json2Order {

	/**
	 * { "picPath": "", //商品图片绝对途径 "payment": 200,
	 * //实付金额。精确到2位小数;单位:元。如:200.07，表示:200元7分 "postFee": 18, //邮费。 "userId":
	 * "13", //用户ID "buyerMessage": "buyerMessage", //买家留言 "buyerNick":
	 * "buyerNick", //用户昵称 "orderItems": [ { "itemId": "2424", //商品id "num": 2,
	 * //购买数量 "title": "title",//标题 "price": 23, //单价 "totalFee": 233 //总金额 } ]
	 * }
	 * 
	 * @return
	 */
	private String getJson() {
		try {
			return FileUtils.readFileToString(new File("C:\\tmp\\order.json"),
					"UTF-8");
		} catch (IOException e) {
		}
		return null;
	}

	@Test
	public void json2Order() throws Exception {
		String json = getJson();
		ObjectMapper objectMapper = new ObjectMapper();
		Order order = objectMapper.readValue(json, Order.class);
		System.out.println(order);
	}

	public static void main(String[] args) {
		// System.out.println(System.currentTimeMillis());

		// 数组排序
		int[][] arr = { { 8, 9, 7 }, { 6, 3, 8 }, { 9, 5, 4 } };
		for (int i = 0; i < arr.length; i++) {
			int[] brr = arr[i];
			for (int j = 0; j < brr.length; j++) {
				for (int j2 = j + 1; j2 < brr.length; j2++) {
					if (brr[j] > brr[j2]) {
						int team = brr[j];
						brr[j] = brr[j2];
						brr[j2] = team;
					}
				}

			}
		}
		
		System.out.println(arr);
	}

}
